import Vue from 'vue'
import Router from 'vue-router'
import Vuex from 'vuex'
import stores from '@/store/index.js'

// = r => require.ensure([], () => r(require('../page/statementAnalysis/index')), 'analysis')
// import index from '@/components/index'//主页
// import enterprise from '@/components/vote/enterprise'//企业投票
// import companyDetail from '@/components/vote/companyDetail'//公司详情
// import signUp  from '@/components/vote/signUp'//报名
const index = r => require.ensure([], () => r(require('@/components/index')), 'index') //主页
const enterprise = r => require.ensure([], () => r(require('@/components/vote/enterprise')), 'enterprise') //企业投票
const companyDetail = r => require.ensure([], () => r(require('@/components/vote/companyDetail')), 'companyDetail') //公司详情
const signUp = r => require.ensure([], () => r(require('@/components/vote/signUp')), 'signUp') //报名

Vue.use(Vuex)
Vue.use(Router)


const routes=new Router({
	mode: 'history',
	routes: [{
			path: '/',
			redirect: 'index'
		},
		{
			path: '/test/index.html',
			name: 'index',
			component: index
		},
		{
			path: '/test/vote/enterprise/:type',
			name: 'enterprise',
			component: enterprise
		},
		{
			path: '/test/vote/signUp',
			name: 'signUp',
			component: signUp
		},
		{
			path: '/index.html',
			name: 'index',
			component: index
		},
		{
			path: '/index',
			name: 'index',
			component: index
		},
		{
			path: '/vote/enterprise',
			name: 'enterprise',
			component: enterprise
		},
		{
			path: '/vote/companyDetail',
			name: 'companyDetail',
			component: companyDetail
		},
		{
			path: '/vote/signUp',
			name: 'signUp',
			component: signUp
		}
	]
})

// routes.beforeEach((to, from, next) => {
// 			stores.commit("changeTitle",'2018挖贝新三板年终评选')
	
// 	　　next()   // 进行下一个钩子函数
// 	})

	export default routes